package hong.jun;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainTest  extends JFrame {
    public MainTest(){
        this.setTitle("JFrameTest");
        this.setSize(200,300);

        //定义一个按钮
        JButton bt =new JButton("按钮");

        this.setLayout(new FlowLayout());
        this.add(bt);
        bt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                MainTest.this.dispose();
            }
        });
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
    public static void main(String[] args)throws Exception{
        new MainTest();
    }
}
